import turtle as t
import easygui as g
import time


def draw_right(draw):
    t.pendown() if draw else t.penup()
    t.right(90)
    t.fd(30)


def draw_left(draw):
    t.pendown() if draw else t.penup()
    t.left(90)
    t.fd(30)


def drawdate(time):
    draw_right(True) if time in [0, 1, 3, 4, 5, 6, 7, 8, 9] else draw_right(False)
    draw_right(True) if time in [0, 2, 3, 5, 6, 8, 9] else draw_right(False)
    draw_right(True) if time in [0, 2, 6, 8] else draw_right(False)
    draw_right(True) if time in [2, 3, 4, 5, 6, 8, 9] else draw_right(False)
    draw_left(True) if time in [0, 1, 2, 3, 4, 7, 8, 9] else draw_left(False)
    draw_left(True) if time in [0, 2, 3, 5, 6, 7, 8, 9] else draw_left(False)
    draw_left(True) if time in [0, 4, 5, 6, 8, 9] else draw_left(False)


def drawmain(date):
    for i in date:
        drawdate(int(i))
        t.left(90)
        t.penup()
        t.fd(100)
        t.pendown()


def localdate(temp):
    # temp = time.strftime('%Y%m%d',time.localtime(time.time()))
    date = list(temp)
    t.pensize(5)
    t.penup()
    t.fd(-250)
    t.pendown()
    drawmain(date)
    t.done()


def main():
    # msg = '请输入一个日期 例如 20150423 '
    # title = '小小蛙日期打印机'
    # g.msgbox('嗨，欢迎进入日期打印机')
    # temp = g.integerbox(msg,title,lowerbound=1,upperbound=99999999)

    msg = '请选择模式'
    title = '小小蛙日期打印机'
    g.msgbox('嗨，欢迎进入日期打印机')
    choices = ['打印当前日期', '打印自定义日期']
    answers = g.choicebox(msg, title, choices)
    if answers == '打印当前日期':
        temp1 = time.strftime('%Y%m%d', time.localtime(time.time()))
        localdate(temp1)
    if answers == '打印自定义日期':
        msg2 = '请输入一个日期 例如 20150423 '
        title = '小小蛙日期打印机'
        temp2 = g.integerbox(msg2, title, lowerbound=1, upperbound=99999999)
        temp2 = str(temp2)
        localdate(temp2)


main()

